home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PAS_0493 / STARS.PAS < prev    next >
Pascal/Delphi Source File  |  1993-04-27  |  2KB  |  98 lines

  1. {─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
  2. Msg  : 423 of 533
  3. From : Daniel Schlenzig                    2:241/5400.10        23 Apr 93  14:42
  4. To   : Stephen Cheok
  5. Subj : STARFIELD
  6. ────────────────────────────────────────────────────────────────────────────────
  7. Hi Stephen,
  8.  
  9.  >         Hmm.. does anyone have an example of a starfield routine in
  10.  > Turbo Pascal.. or can be used with Turbo Pascal.. using the
  11.  > ASSEMBLER..  I want to try to make one.. but I need some help with
  12.  > it.  Thanx...
  13. Here is one: }
  14.  
  15. program stars;
  16.  
  17. const maxstars = 200;
  18.  
  19. var star  : array[0..maxstars] of word;
  20.     speed : array[0..maxstars] of byte;
  21.     i     : word;
  22.  
  23. procedure create;
  24. begin
  25.   for i := 0 to maxstars do begin
  26.     star[i] := random(320) + random(200) * 320;
  27.     speed[i] := random(3) + 1;
  28.     if mem[$a000:star[i]] = 0 then mem[$a000:star[i]] := 100;
  29.   end;
  30. end;
  31.  
  32. Procedure moveit; assembler;
  33. asm
  34.      xor   bp,bp
  35.      mov   ax,0a000h
  36.      mov   es,ax
  37.      lea   bx,star
  38.      lea   si,speed
  39.      mov   cx,320
  40.  
  41. @l1: mov   di,[bx]
  42.      mov   al,es:[di]
  43.      cmp   al,100
  44.      jne   @j1
  45.      xor   al,al
  46.      stosb
  47. @j1: mov   al,[si]
  48.      xor   ah,ah
  49.      add   [bx],ax
  50.      mov   ax,bx
  51.      xor   dx,dx
  52.      div   cx
  53.      mul   cx
  54.      mov   dx,bx
  55.      sub   dx,ax
  56.      cmp   dx,319
  57.      jle   @j3
  58.      sub   [bx],cx
  59. @j3: mov   di,[bx]
  60.      mov   al,es:[di]
  61.      or    al,al
  62.      jnz   @j2
  63.      mov   al,100
  64.      stosb
  65. @j2: add   bx,2
  66.      inc   si
  67.      inc   bp
  68.      cmp   bp,maxstars
  69.      jle   @l1
  70. end;
  71.  
  72. begin
  73.   asm
  74.     mov   ax,13h
  75.     int   10h
  76.     call  create
  77.  
  78. @l1:
  79.     mov   dx,3dah
  80. @r1:
  81.     in    al,dx
  82.     test  al,8
  83.     je    @r1
  84.  
  85.     call moveit
  86.     in   al,60h
  87.     cmp  al,1
  88.     jne  @l1;
  89.   end;
  90. end.
  91.  
  92. Well, it can be done faster, but it' s enough to learn from :-)
  93. cu Daniel
  94.  
  95. --- GEcho 1.00
  96.  * Origin: Don't panic! (2:241/5400.10)
  97.  
  98.